//
//  QSChineseValidateTool.swift
//  BeeBoxClient
//
//  Created by Song on 2020/1/10.
//  Copyright © 2020 Song. All rights reserved.
//

import UIKit

class QSChineseValidateTool: NSObject {
    /// 获取文件中的字符串
    func getFileContent(fileName: String) -> String? {
        let path = Bundle.main.path(forResource: fileName, ofType: nil)!
        let sss = try? String.init(contentsOfFile: path, encoding: .utf8)
        
        return sss
    }
    
    // 判断是否有中文
    func hasChinese(str: String) -> Bool {
        let emailRegex = ".*[\\u4e00-\\u9fa5]+.*$"
        let emailTest:NSPredicate = NSPredicate(format: "SELF MATCHES %@", emailRegex)
        let isInclude = emailTest.evaluate(with: str)
        
        return isInclude
    }
}
